<?php
@session_start();
 require_once("core.php");
 get_all_variables();

 function getStatsByProblemId($problem_id) {
  $db = dbconnect();
  $q = "SELECT *
        FROM `submits`
        WHERE (problem_id=\"$problem_id\")AND(client_id=".$_SESSION['client'].")
        ORDER BY `id` DESC";

  $r = mysql_query($q, $db) or die (mysql_error());
  $n = 0;
  @$n = mysql_num_rows($r);
  if ($n == 0) {
      return "Not Submitted";
  } else
  {
      $w = mysql_fetch_array($r);
      return $w['result'];
  }
 }

 function getStats2ByProblemId($problem_id) {
  $db = dbconnect();
  $q = "SELECT *
        FROM `submits`
        WHERE (problem_id=\"$problem_id\")AND(client_id=".$_SESSION['client'].")
        ORDER BY `id` DESC";

  $r = mysql_query($q, $db) or die (mysql_error());
  $n = 0;
  @$n = mysql_num_rows($r);
  if ($n == 0) {
      return "Not Submitted";
  } else
  {
      $w = mysql_fetch_array($r);
      return $w['time'];
  }
 }

 function getStats3ByProblemId($problem_id) {
  $db = dbconnect();
  $q = "SELECT *
        FROM `submits`
        WHERE (problem_id=\"$problem_id\")AND(client_id=".$_SESSION['client'].")
        ORDER BY `id` DESC";

  $r = mysql_query($q, $db) or die (mysql_error());
  $n = 0;
  @$n = mysql_num_rows($r);
  if ($n == 0) {
      return "Not Submitted";
  } else
  {
      $w = mysql_fetch_array($r);
      return $w['lang'];
  }
 }
?>

<p class="p_title">Stats</p>
              <ul class="top5" style="width: 160px; display: inline-block;">
		     <li><b>A.</b> <? echo getStatsByProblemId("A"); ?></li>
                     <li><b>B.</b> <? echo getStatsByProblemId("B"); ?></li>
                     <li><b>C.</b> <? echo getStatsByProblemId("C"); ?></li>
                     <li><b>D.</b> <? echo getStatsByProblemId("D"); ?></li>
                     <li><b>E.</b> <? echo getStatsByProblemId("E"); ?></li>
               </ul>

	      <ul class="top5" style="width: 160px; display: inline-block;">
		     <li> <? echo getStats2ByProblemId("A"); ?></li>
                     <li> <? echo getStats2ByProblemId("B"); ?></li>
                     <li> <? echo getStats2ByProblemId("C"); ?></li>
                     <li> <? echo getStats2ByProblemId("D"); ?></li>
                     <li> <? echo getStats2ByProblemId("E"); ?></li>
               </ul>

	      <ul class="top5" style="width: 160px; display: inline-block;">
		     <li> <? echo getStats3ByProblemId("A"); ?></li>
                     <li> <? echo getStats3ByProblemId("B"); ?></li>
                     <li> <? echo getStats3ByProblemId("C"); ?></li>
                     <li> <? echo getStats3ByProblemId("D"); ?></li>
                     <li> <? echo getStats3ByProblemId("E"); ?></li>
               </ul>

